/*
 * Copyright (C) 2010 恒康信息科技有限公司
 * 版权所有
 */
package com.jjmmbb.stockdiary.db;

import java.util.Locale;

import android.database.sqlite.SQLiteDatabase;

import com.jjmmbb.stockdiary.Util;

public class SqlForDBCreate {

	public static void CreateDatabase(SQLiteDatabase db) {
		create_daiban(db);
	}

	public static void create_daiban(SQLiteDatabase db) {
		db.execSQL("DROP TABLE IF EXISTS daiban");

		// 购物车表,只保存和数量;标题和价格需要从服务器获取
		StringBuilder sql = new StringBuilder();
		sql.append("CREATE TABLE IF NOT EXISTS daiban (");
		sql.append(" id INTEGER PRIMARY KEY AUTOINCREMENT,"); // 这个属性不能修改,这一列不能修改
		sql.append(" title TEXT,"); // 标题
		sql.append(" des TEXT,"); // 描述
		sql.append(" team TEXT,"); // 组
		sql.append(" type INTEGER,"); // 列表:待办,完成,已删除
		sql.append(" typeAlarm INTEGER,"); // -1、提醒完成,-2、需要提醒,-3、循环提醒(每天),大于0、按星期提醒(二进制标记算法)
		sql.append(" timeAlarm LONG,"); //
		sql.append(" timeFinish LONG,"); //
		sql.append(" timePlanComplete LONG,"); //
		sql.append(" time TEXT)"); // 最后编辑时间
		db.execSQL(sql.toString());

		insert_daiban(db);
	}

	public static void insert_daiban(SQLiteDatabase db) {
		String languageName = Locale.getDefault().getLanguage();
		if (languageName.equals("zh")) {
			String time = Util.getFormateTime();
			db.execSQL("insert into daiban (title,type,time) values ('下拉新建',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('右拖动标题刷新',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('左拖动标题扫描二维码',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('二维码扫描记事',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('购物清单',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('待办事项',0,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('已完成',1,'"
					+ time + "')");
			db.execSQL("insert into daiban (title,type,time) values ('已删除',2,'"
					+ time + "')");
		}
	}

}
